package com.mxl.service.cashorder.rule;

import javax.annotation.Resource;

import com.mxl.common.helper.ResponseErrorCode;
import com.mxl.common.rule.AbstractRule;
import com.mxl.dao.cashorder.CustomMerchantDao;
import com.mxl.dao.cashorder.model.CustomMerchant;
import com.mxl.service.cashorder.dto.CashOrderRequest;

/**
 * 判断商户时候支持此卡支付
 * 
 * @author xianglin.mo
 * 
 */
public class MemberBossTypeSupperCheck extends AbstractRule {

	@Resource(name = "customMerchantDao")
	private CustomMerchantDao customMerchantDao;

	@Override
	protected boolean makeDecision(Object obj) throws Exception {

		CashOrderRequest c = (CashOrderRequest) obj;
		CustomMerchant cust = customMerchantDao.findByMembercodeAndBosstype(
				c.getMemberCode(), c.getBossType());
		if (cust == null) {
			c.setMsgId(ResponseErrorCode.MEMBER_CARD_NOT_SUPPER.getValue());
			return false;
		}
		return true;
	}

}
